package com.crazymaker.springcloud.message.config;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.ArrayList;
import java.util.List;

@NoArgsConstructor
@Getter
@Setter
@ConfigurationProperties(prefix = "sharding.datasource")
public class DataSourceProperties {
    private String type;
    private String driverClassName;
    private String url;
    private String username;
    private String password;
    private String ruleConfig;

    private List<MultiConn> multiConn = new ArrayList<>();
    private DruidProperties druid = new DruidProperties();

    @NoArgsConstructor
    @Getter
    @Setter
    public static class MultiConn {

        private String url;
        private String username;
        private String password;

    }


    @NoArgsConstructor
    @Getter
    @Setter
    public static class DruidProperties {

        private Integer initialSize;
        private Integer minIdle;
        private Integer maxActive;
        private Long maxWait;
        private Long timeBetweenEvictionRunsMillis;
        private Long minEvictableIdleTimeMillis;
        private String validationQuery;
        private boolean testWhileIdle;
        private boolean testOnBorrow;
        private boolean testOnReturn;
        private boolean poolPreparedStatements;
        private Integer maxPoolPreparedStatementPerConnectionSize;
        private String filters;
        private String connectionProperties;
        private boolean useGlobalDataSourceStat;
        private String loginUsername;
        private String loginPassword;

    }


}

